﻿using AntdUI;
using CKS.MES.Server.Demo;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CKS.MES.Server.UserControls
{
    public partial class MoldPositionControl : UserControl
    {
        public MoldPositionControl()
        {
            InitializeComponent();
            Init(true);
        }


        void Init(bool reverse)
        {
            //table1.EditMode = TEditMode.None;
            //table1.Columns = new ColumnCollection();
            //table1.RowSelectedBg = Color.Transparent;
            //table1.RowHoverBg = Color.Transparent;
            //table1.Bordered = true;
            //table1.BorderColor = Color.Green;

            //table1.Columns.Add(new Column("Code", "工位") { Width = "80" });
            //table1.Columns.Add(new Column("Name", "工位名称"));
            //table1.Columns.Add(new Column("State", "状态") { Width = "80" });
            //table1.Columns.Add(new Column("OkCount", "OK数量"));
            //table1.Columns.Add(new Column("NgCount", "NG数量"));

            //设计时窗体大小 626 333

            
            lb3.Text = "1-72";
            InitOneGroupShelf(pnlColumn3,1,72);

            InitOneGroupShelf(pnlColumn2,73,144);
            lb2.Text = "73-144";
            InitOneGroupShelf(pnlColumn1, 145, 216);
            lb1.Text = "145-216";
        }


  


        /// <summary>
        /// 初始化1组货格
        /// </summary>
        private void InitOneGroupShelf(AntdUI.Panel pnl,int start,int end )
        {
            GridPanel grid1 = new GridPanel();
            grid1.Span = "12.5%";

            int row = 9;
            int col = 8;

            List<string> temps = new List<string>();
            for (int i = 0; i < col; i++)
            {
                temps.Add("12.5%");
            }
            string rowSpan = string.Join(" ", temps.ToArray());
            temps.Clear();
            for (int i = 0; i < row; i++)
            {
                temps.Add(rowSpan);
            }
            string allspan = string.Join(";", temps.ToArray());
            grid1.Span = allspan;

            List<ShelfCell> scs = new List<ShelfCell>();

           
            for (int i = start; i <= end; i++)
            {
                scs.Add(new ShelfCell() { Id = i });
             
            }
          
            foreach (var item in scs)
            {
                Avatar avatar = new Avatar();
                avatar.BackColor = Color.White;
                avatar.Tag = item;
                if (item.Id == 1 || item.Id == 8)
                {
                    avatar.Text = item.Id.ToString();
                }
                grid1.Controls.Add(avatar);

            }
            pnl.Controls.Add(grid1);
            grid1.Dock = DockStyle.Fill;
            grid1.BringToFront();
        }
    }

    class ShelfCell
    {
        /// <summary>
        /// 编号
        /// </summary>
        public int Id { get; set; }


    }
}
